<%-- 
    Document   : printpdma
    Created on : Jan 1, 2012, 11:08:44 AM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*, java.text.NumberFormat,Beans.ThamSoHT,Models.ThamSoHT_Model, Models.MonAn_Model, Models.PhieuDatMA_Model, Models.TienTe_Model, Models.DonViTinh_Model"%>
<!--
Danh sách các tham số hệ thống ở trang này :
order      areainfo     areamsg     status      arealang
newarea    areaname     save        action      arealist
enable     disable      search
-->
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'foodname', 'price', 'sl', 'dvt', 'orderbill', 'promotionbill', 'table', 'servicecharge', 'total',  'reduction' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.
            
            String dvt = mdsts[0].getTenTS();
            String foodname = mdsts[1].getTenTS();
            String orderbill = mdsts[2].getTenTS();
            String price = mdsts[3].getTenTS();
            String promotionbill = mdsts[4].getTenTS();
            String reduction = mdsts[5].getTenTS();
            String servicecharge = mdsts[6].getTenTS();
            String sl = mdsts[7].getTenTS();
            String table = mdsts[8].getTenTS();
            String total = mdsts[9].getTenTS();
            
            Vector v = (Vector) request.getAttribute("PDMA");
            Vector vDetail = (Vector) request.getAttribute("Detail");
            String tendn = (String) request.getAttribute("tendn");
            String diachi = (String) request.getAttribute("diachi");
            String sodt = (String) request.getAttribute("sodt");
            String ngaygio = (String) request.getAttribute("ngaygio");
            int sohdt = 0;
            double tamtinh = 0;
            int maban = 0;
            double thanhtien = 0;
            int ppv =0;
            double tienpv = 0;
            int chietkhau = 0;
            double tienchietkhau = 0;
            double km = 0;
            NumberFormat nf = NumberFormat.getNumberInstance(Locale.FRENCH);

%>
<html>
    <head>
        <link href="css/statics.css" type="text/css" rel="stylesheet" />
        <title>i-Order</title>
        <link rel="icon" href="images/icon.png" />
        <link rel="shortcut icon" href="images/icon.png" />
        <link rel="apple-touch-icon" href="images/icon.png"/>
        <link rel="apple-touch-icon-precomposed" href="images/icon.png"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <div style=" background: #f5e3c0; width: 35%; padding: 10px;">
        <div>
            <div style="text-align: left; text-transform: uppercase; font-size: 20px; margin-bottom: 10px; color: #242323; font-weight: bold;"><%=tendn%></div>
            <div style="text-align: left; margin-bottom: 5px; color: #242323;"><img style=" margin-right: 8px;" alt="" src="images/download2.png"><%=diachi%></div>
            <div style="text-align: left; margin-bottom: 5px; color: #242323;"><img style=" margin-right: 5px;" alt="" src="images/phone.png"><%=sodt%></div>
        </div>
        <div style="text-transform: uppercase; clear: both; font-size: 18px; margin-bottom: 20px; font-weight: bold; text-align: center; margin-top: 15px;"><%=orderbill%></div>
        <div style="">
            <%
                for (int i = 0; i < v.size(); i++) {
                    Beans.PhieuDatMA p = (Beans.PhieuDatMA) v.elementAt(i);
                    sohdt = p.getSoHDT();
                    tamtinh = p.getTongCong();
                    maban = p.getMaBan();
                    thanhtien = p.getThanhTien();
                    ppv = p.getPhiPhucVu();
                    tienpv = (thanhtien * ppv)/100;
                    chietkhau = p.getChietKhau();
                    tienchietkhau = (thanhtien * chietkhau)/100;
                    km = p.getKMHoaDon();
            %>
            <table style="">
                <tr>
                    <td style="width: 50px; color: #242323; font-weight: bold;"><%=table%></td>
                    <td style="width: 50px; color: #242323;"><%=PhieuDatMA_Model.LayTenBan(p.getMaBan())%></td>
                    <td style=" width: 250px;"></td>
                    <td style="width: 50px; color: #242323; text-align: right;"><%=p.getSoHDT()%></td>
                </tr>
                <tr>
                    <td colspan="2" style=" color: #242323;">(<%=PhieuDatMA_Model.LayTenKV(p.getMaBan(), langid) %>)</td>
                    <td colspan="2" style=" text-align: right;"><%=p.getGioVao() %></td>
                </tr>                
            </table><br />            
            <%  }%>
            <table style=" clear: both;">
                <tr style="">
                    <td style="width: 31%; color: #242323; font-weight: bold; "><%=foodname%></td>
                    <td style="width: 20%; color: #242323; font-weight: bold; "><%=price%> (<%=TienTe_Model.LayKyHieuTT(langid)%>)</td>
                    <td style="width: 7%; color: #242323; font-weight: bold; "><%=sl%></td>
                    <td style="width: 13%; color: #242323; font-weight: bold; "><%=dvt%></td>
                    <td style="color: #242323; font-weight: bold; "><%=total%> (<%=TienTe_Model.LayKyHieuTT(langid)%>)</td>
                </tr>
                <tr><td colspan="5" style="border-bottom: 1px solid #242323;"></td></tr>
                <tbody>
            <%
                for(int j=0; j<vDetail.size(); j++){
                    Beans.CTPhieuDatMA c = (Beans.CTPhieuDatMA) vDetail.elementAt(j);%>
                <tr>
                    <td style="color: #242323;"><%=MonAn_Model.LayTenMA(c.getMaMA(), langid)  %></td>
                    <td style="color: #242323;"><div style=" width: 55px; float: left; text-align: right; "><%=nf.format(c.getGia()) %></div></td>
                    <td style="color: #242323;"><%=c.getSoLuong() %></td>
                    <td style="padding-left: 10px;color: #242323;"><%=DonViTinh_Model.LayTenDVT(c.getMaDVT(), langid)  %></td>
                    <td style="color: #242323;"><div style="width: 65px; float: left; text-align: right; "><%=nf.format(c.getThanhTien()) %></div></td>
                </tr>
                <%  }%>
                <tr><td colspan="5" style="border-bottom: 1px solid #242323;"></td></tr>
                <tr>
                    <td style=" font-weight: bold; color: #242323;"><%=total%></td>
                    <td></td><td></td><td></td>
                    <td><div style=" float: left; width: 65px; text-align: right;"><%=nf.format(thanhtien)%></div></td>
                </tr>
                <%  if(ppv != 0){%>
                <tr>
                    <td style=" color: #242323;"><%=servicecharge%></td>
                    <td></td><td></td>
                    <td style="color: #242323;"><div style=" float: left; width: 20px;"><%=ppv%></div> %</td>
                    <td><div style=" width: 65px; text-align: right; color: #242323;"><%=nf.format(tienpv)%></div></td>
                </tr>
                <%  }%>
                <%  if(chietkhau != 0){%>
                <tr>
                    <td style=" color: #242323;"><%=reduction%></td>
                    <td></td><td></td>
                    <td style="color: #242323;"><div style=" float: left; width: 20px;"><%=chietkhau%></div> %</td>
                    <td><div style=" width: 65px; text-align: right; color: #242323;"><%=nf.format(tienchietkhau)%></div></td>
                </tr>
                <%  }%>
                <%  if(km != 0){%>
                <tr>
                    <td style=" color: #242323;"><%=promotionbill%></td>
                    <td></td><td></td><td></td>
                    <td><div style=" width: 65px; text-align: right; color: #242323;"><%=nf.format(km)%></div></td>
                </tr>
                <%  }%>
                <tr><td colspan="5" style="border-bottom: 2px solid #242323;"></td></tr>
                <tr>
                    <td style=" font-weight: bold; color: #242323;"><%=total%></td>
                    <td></td><td></td><td></td>
                    <td><div style=" float: left; width: 65px; font-weight: bold; text-align: right;"><%=nf.format(tamtinh)%></div></td>
                </tr>
            </tbody>
            </table>
        </div>
                </div>
    </body>
</html>
